<?php $this->load->view('admin/header');?>

    <div class="main clear">
        <div class="table02">
            <form id="article_form" onsubmit="return check();" action="/index.php?d=admin&c=article_edit&m=save" method="post">
                <div class="add_item" style="margin-top: 10px;">
                    <label>文章标题：</label>
                    <input id="title" class="txt width500" type="text" name="title" value="<?php if(!empty($info['title'])){echo $info['title'];}?>">
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>推荐标题：</label>
                    <input id="subtitle" class="txt width500" type="text" name="subtitle" value="<?php if(!empty($info['subtitle'])){echo $info['subtitle'];}?>">
                </div>
                <div class="add_item">
                    <label>自定义属性：</label>
                    <div id="flag_val" style="display: none"><?php if(!empty($info['flag'])){echo $info['flag'];}?></div>
                    <div id="flag" >
                        <input class="checkbox" type="checkbox" value="a" name="flag[]" >
                        <span>首页推荐（a）</span>
                        <input class="checkbox" type="checkbox" value="l" name="flag[]">
                        <span>首页头条（l）</span>
                        <input class="checkbox" type="checkbox" value="t" name="flag[]">
                        <span>首页侧边栏（t）</span>
                    </div>
                    <script type="text/javascript">
                        var flag = $('#flag_val').html();
                        var tjarr = flag.split(',');
                        $(function(){
                            $('#flag input').each(function(){
                                for(var j=0;j<tjarr.length;j++){
                                    if($(this).val() == tjarr[j]){
                                        $(this).attr('checked','checked');
                                    }
                                }
                            })
                        })
                    </script>
                </div>

                <div class="add_item" style="margin-top: 10px;">
                    <label>订阅词：</label>
                    <input id="tags" class="txt width500" type="text" name="tag" onblur="javascript:chack_tag()" value="<?php if(!empty($info['tag'])){echo $info['tag'];}?>">
                    <span id="ktj_tag"></span>
                </div>
                <div class="add_item" style="margin-top: 10px;">
                    <label>订阅词库：<br/>(点击生效)&nbsp;</label>
                    <?php if(!empty($tag_list)){ ?>
                        <?php foreach($tag_list as $v){?>
                            <a href="javascript:void(0)" onclick="addtag('<?php echo $v['tagname'];?>')"><?php echo $v['tagname'];?></a>
                        <?php }?>
                    <?php }?>
                </div>
                <script type="text/javascript">
                    function addtag(tagname){
                        var tagnow = $('#tags').val();

                        if(tagnow.length==0){
                            var tagnew = tagname;
                        }else{
                            var tagnew = tagnow+'，'+tagname;
                        }
                        $('#tags').val(tagnew);
                        $('#tags').focus();
                    }
                    function chack_tag(){
                        var tagnow = $('#tags').val();
                        if(tagnow.length>0){
                            $.ajax({
                                type : 'post',
                                async : false,
                                url  : "/index.php?d=admin&c=article_edit&m=chack_tag",
                                data : 'tags='+tagnow,
                                success:function(data){
                                   data = '<a href="/index.php?d=admin&c=tag&m=edit" target="_blank">添加标签</a>可添加标签：' + data;
                                   $('#ktj_tag').html(data);
                                }
                            })
                        }
                    }

                </script>
                <div class="add_item">
                    <label>首页缩略图：</label>
                    <input type="text" value="<?php if(isset($info['flash_pic'])){echo $info['flash_pic'];}?>"  name="flash_pic" class="txt width500" id="flash_pic">
                    <input type="hidden" id="h_pic">
                    <a onclick="showupwindow('flash_pic')" href="javascript:;">上传</a>
                </div>
                <div class="add_item">
                    <label>列表页缩略图：</label>
                    <input type="text" value="<?php if(isset($info['litpic'])){echo $info['litpic'];}?>"  name="flash_pic" class="txt width500" id="flash_pic">
                    <input type="hidden" id="h_pic">
                    <a onclick="showupwindow('litpic')" href="javascript:;">上传</a>
                </div>
                <div class="add_item">
                    <label>栏目：</label>
                    <select name="typeid">
                        <option value="0">--栏目选择--</option>
                        <?php foreach($type_arr as $k=>$v):?>
                            <option value="<?php echo $k;?>" <?php if($info['typeid'] == $k){echo 'selected="selected"';}?> ><?php echo $v;?></option>
                        <?php endforeach;?>
                    </select>
                    <label>来源：</label>
                    <input id="source" class="txt" style="width: 100px" type="text" name="source" value="<?php if(!empty($info['source'])){echo $info['source'];}?>">
                    <label>作者：</label>
                    <input id="writer" class="txt" style="width: 100px" type="text" name="writer" value="<?php if(!empty($info['writer'])){echo $info['writer'];}?>">
                    <label>发布时间：</label>
                    <input id="pubtime" class="txt" style="width: 200px" type="text" name="pubtime" value="<?php if(!empty($info['pubtime'])){echo $info['pubtime'];}?>">
                </div>
                <div class="editor_box">
                    <label>文章关键词：</label>
                    <input id="subtitle" class="txt width500" type="text" name="keywords" value="<?php if(!empty($info['keywords'])){echo $info['keywords'];}?>">
                </div>
                <div class="editor_box">
                    <label>文章描述：</label>
                    <span style="float: left;">
                        <textarea style="width: 500px; height: 200px;" id="description" name="description"><?php if(isset($info['description'])){echo $info['description'];}?></textarea>
                    </span>
                </div>
                <div class="editor_box">
                    <label>文章内容：</label>
                    <span style="float: left;">
                        <textarea style="width: 1000px; height: 690px;" id="body" name="body"><?php if(isset($info['content'])){echo $info['content'];}?></textarea>
                    </span>
                    <script type="text/javascript">
                        <!-- 实例化编辑器 -->
                        var ue = UE.getEditor('body');
//                        $(function(){
//                            $('#body').xheditor({upImgUrl:'!/static/xheditor/xheditor_plugins/multiupload/multiupload.html',upFlashUrl:'/static/xheditor/xheditor_plugins/multiupload/multiupload.html',upMediaUrl:'/static/xheditor/xheditor_plugins/multiupload/multiupload.html'});
//                        })
                    </script>
                </div>
                <div class="btn_box">
                    <input type="hidden" value="<?php if(isset($info['id']) && !empty($info['id'])){echo $info['id'];}?>" name="id">
                    <input type="submit" name="" value="保存">
                    <input type="button" name="" value="返回" onclick="fanhui()">
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        function fanhui(){
            history.back();
        }
        function showupwindow(id){
            $('#h_pic').val(id);
            $('body').append('<div style="width: 349px; height: 220px; margin-left: -175px; margin-top: -110px; top: 355px;" class="xheModal" id="div_up"><div class="xheModalTitle"><span title="关闭 (Esc)" class="xheModalClose" onclick="close_up()"></span>上传文件</div><div class="xheModalContent" style="height: 191px;"><iframe frameborder="0" style="width: 100%; height: 100%;" src="/static/xheditor/xheditor_plugins/multiupload/multiupload.html?watermark=0"></iframe></div></div>');
            $('#div_up').css('top', $(document).scrollTop() + (window.screen.availHeight / 2 - 80));
        }

        function close_up(){
            $('#div_up').remove();
        }
        function fanhui(){
            history.back();
        }

        function check()
        {
            if($('#title').val()=='')
            {
                alert('请输入名称');
                $('#title').focus();
                return false;
            }
            return true;
        }
    </script>


<?php $this->load->view('admin/footer');?>